import request from "../api/request";
import config  from "../setting";

function myRequest(url, method = 'get', params, headers = {}) {
    // const baseURL = 'http://adm.clapring.cn'
    const baseURL = config.appUrl
    if (method === 'get') {
      return request({ baseURL, url, method, params, headers })
    } else {
      return request({ baseURL, url, method, data: params, headers })
    }
  }
  function handleGet(url, params, headers) {
    return myRequest(url, 'get', params, headers)
  }
  function handlePost(url, data, headers) {
    return myRequest(url, 'post', data, headers)
  }

// 用法示例
  export const gameaddby3399 = (params, headers) => handleGet('/api/reg_developer', params ,headers);

// 个人开发者认证
export const reg_developer = (params, headers) => handlePost('/api/reg_developer', params,headers);
// 企业开发者认证
export const reg_company_developer = (params, headers) => handlePost('/api/reg_company_developer', params,headers);
// 登录
// export const userLogin = (params, headers) => handlePost('/api/auth/login', params,headers);
// 通用手机号、帐号、邮箱、ID密码登录
export const userLogin = (params, headers) => handlePost('/api/auth/new_password_login', params,headers);
// 手机号码登录
// export const userLoginByPhone = (params, headers) => handlePost('/api/loginByPhone', params,headers);
export const userLoginByPhone = (params, headers) => handlePost('/api/auth/phone_login', params,headers);
// 发送验证码
export const sendCode = (params, headers) => handleGet('/api/auth/sendCode', params,headers);